package com.jh.user.pojo;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.Objects;

import javax.persistence.*;

import com.fasterxml.jackson.annotation.JsonFormat;


@Entity
@Table(name="t_user_role")
public class UserRole implements Serializable{


	private static final long serialVersionUID = 1L;

	@Id
	@Column(name="id")
	private long id;
	
	@Column(name="user_id")
	private long userId;

	@Column(name="brand_id")
	private long brandId;

	@Column(name="certigieruser_id")
	private long certigieruserId;
	
	@Column(name="role_id")
	private long roleId;
	
	@Column(name="status")
	private String status;
	
	@Column(name="create_time")
	@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
	private Date createTime;

	@Transient
	private String phone;

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public long getBrandId() {
		return brandId;
	}

	public void setBrandId(long brandId) {
		this.brandId = brandId;
	}

	public long getCertigieruserId() {
		return certigieruserId;
	}

	public void setCertigieruserId(long certigieruserId) {
		this.certigieruserId = certigieruserId;
	}



	public long getId() {
		return id;
	}


	public void setId(long id) {
		this.id = id;
	}


	public long getUserId() {
		return userId;
	}


	public void setUserId(long userId) {
		this.userId = userId;
	}


	public long getRoleId() {
		return roleId;
	}


	public void setRoleId(long roleId) {
		this.roleId = roleId;
	}


	public String getStatus() {
		return status;
	}


	public void setStatus(String status) {
		this.status = status;
	}


	public Date getCreateTime() {
		return createTime;
	}


	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}


	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (!(o instanceof UserRole)) return false;
		UserRole userRole = (UserRole) o;
		return getId() == userRole.getId() &&
				getUserId() == userRole.getUserId() &&
				getBrandId() == userRole.getBrandId() &&
				getCertigieruserId() == userRole.getCertigieruserId() &&
				getRoleId() == userRole.getRoleId() &&
				Objects.equals(getStatus(), userRole.getStatus()) &&
				Objects.equals(getCreateTime(), userRole.getCreateTime());
	}

	@Override
	public int hashCode() {
		return Objects.hash(getId(), getUserId(), getBrandId(), getCertigieruserId(), getRoleId(), getStatus(), getCreateTime());
	}

	@Override
	public String toString() {
		return "UserRole{" +
				"id=" + id +
				", userId=" + userId +
				", brandId=" + brandId +
				", certigieruserId=" + certigieruserId +
				", roleId=" + roleId +
				", status='" + status + '\'' +
				", createTime=" + createTime +
				'}';
	}

	public static UserRole initUserRole(long userId, long brandId) {
		UserRole userRole = new UserRole();
		userRole.setUserId(userId);
		userRole.setBrandId(brandId);
		userRole.setRoleId(5);
		userRole.setStatus("0");
		userRole.setCreateTime(Calendar.getInstance().getTime());
		return userRole;
	}
}
